--罗技鼠标宏LUA语言,参考文档:G-series Lua API

Hege_Macro_LoopInterval = 10 --脚本循环间隔（毫秒）

EnablePrimaryMouseButtonEvents(true)  --开启响应鼠标事件

function OnEvent(event, arg, family)
	--if (event == "G_RELEASED" and arg == 4) then --4为罗技键盘G4键
	if (event == "MOUSE_BUTTON_RELEASED" and arg == 6 and IsKeyLockOn("scrolllock")) then --这里的3为罗技鼠标中键，4-9数字为鼠标侧键
		dianyunshi()
	end

	if (event == "MOUSE_BUTTON_RELEASED" and arg == 6 and IsKeyLockOn("capslock")) then --这里的3为罗技鼠标中键，4-9数字为鼠标侧键
		houniaoshushua()
	end

	if (event == "MOUSE_BUTTON_RELEASED" and arg == 4 and IsKeyLockOn("scrolllock")) then --这里的3为罗技鼠标中键，4-9数字为鼠标侧键
		--xfz()
	end
end

-------------------------------------------------------------------------------------------------------------------------------

--F2：站立攻击
--F7：强制移动

--F3键（暗黑3导航功能键）：快速拾取装备、分解背包装备、血岩购买装备
---------------------------通用--------------------------
--左键技能
function zoujian()
	while (IsKeyLockOn("scrolllock")) do
		if (IsModifierPressed("rshift")) then
			PressKey("f2")
			Sleep(100)
			PressAndReleaseMouseButton(1)--点击左键
			Sleep(100)
		end
		ReleaseKey("f2")
	end
	ReleaseKey("f2")
end


-------------------------魔法师-------------------------

--提丰电蛇刷蓝门，上帝电陨速刷悬赏蓝门小秘境大秘境100、522冰或奥陨刷速大秘境110
function dianyunshi()
	if (IsKeyLockOn("scrolllock")) then
		--左键技能
		PressKey("f2")
		Sleep(25)
		PressAndReleaseMouseButton(1)--点击左键
		Sleep(20)
		ReleaseKey("f2")
		Sleep(55)

		PressAndReleaseKey("2")
		Sleep(60)
		PressAndReleaseKey("3")
		Sleep(65)
		PressAndReleaseKey("4")
		Sleep(70)

		Times_Key_F7 = 0
		Times_Key_1 = 0
		Times_Key_2 = 0
		Times_Key_3 = 0
		Times_Key_4 = 0
		Times_Key_5 = 0
		Times_Key_6 = 0
	end

	--如果scrolllock键已按下则启动循环，否则退出循环
	while (IsKeyLockOn("scrolllock")) do
		Sleep(Hege_Macro_LoopInterval) --循环间隔

		Times_Key_F7 = Times_Key_F7 + 1
		Times_Key_1 = Times_Key_1 + 1
		Times_Key_2 = Times_Key_2 + 1
		Times_Key_3 = Times_Key_3 + 1
		Times_Key_4 = Times_Key_4 + 1
		Times_Key_5 = Times_Key_5 + 1
		Times_Key_6 = Times_Key_6 + 1

		--每N秒按下并释放F7键（强制移动）
		if ((Times_Key_F7*Hege_Macro_LoopInterval) >= 80) then
			if not (IsMouseButtonPressed(3)) then  --如果右键没有按下，这里的3是鼠标右键
				if (IsModifierPressed("rshift")) then --按住rshift键中断强制移动
					PressAndReleaseMouseButton(1)--点击左键
				else
					PressAndReleaseKey("f7")--点击F7键
				end
			end
			Times_Key_F7 = 0
		end

		--每N秒按下并释放1键
		if ((Times_Key_1*Hege_Macro_LoopInterval) >= 200) then
			--PressAndReleaseKey("1")
			Times_Key_1 = 0
		end

		--每N秒按下并释放2键
		if ((Times_Key_2*Hege_Macro_LoopInterval) >= 300) then
			PressAndReleaseKey("2")
			Times_Key_2 = 0
		end

		--每N秒按下并释放3键
		if ((Times_Key_3*Hege_Macro_LoopInterval) >= 500050) then
			PressAndReleaseKey("3")
			Times_Key_3 = 0
		end

		--每N秒按下并释放4键
		if ((Times_Key_4*Hege_Macro_LoopInterval) >= 500070) then
			PressAndReleaseKey("4")
			Times_Key_4 = 0
		end

		--每N秒按下并释放鼠标左键
		if ((Times_Key_5*Hege_Macro_LoopInterval) >= 500000) then
			PressKey("f2")
			Sleep(20)
			PressAndReleaseMouseButton(1)--点击左键
			Sleep(25)
			ReleaseKey("f2")
			Times_Key_5 = 0
		end

		--每N秒按下并释放鼠标右键
		if ((Times_Key_6*Hege_Macro_LoopInterval) >= 28000) then
			PressAndReleaseMouseButton(3)--点击右键
			--Times_Key_6 = 0
		end
		if ((Times_Key_6*Hege_Macro_LoopInterval) >= 29000) then
			PressAndReleaseMouseButton(3)--点击右键
			Times_Key_6 = 0
		end
	end

	--循环结束，释放鼠标和按键
	ReleaseKey("f2")--释放F2键（强制站立）
	ReleaseKey("f7")--释放F7键（强制移动）
end


--火鸟速刷大秘境120
function houniaoshushua()
	if (IsKeyLockOn("capslock")) then
		--左键技能
		PressKey("f2")
		Sleep(25)
		PressAndReleaseMouseButton(1)--点击左键
		Sleep(20)
		ReleaseKey("f2")
		Sleep(55)
		PressAndReleaseKey("3")
		Sleep(55)
		PressAndReleaseKey("4")
		Sleep(100)

		PressMouseButton(3)--按下右键

		Times_Key_1 = 0
		Times_Key_2 = 0
		Times_Key_3 = 0
		Times_Key_4 = 0
		Times_Key_5 = 0
		Times_Key_6 = 0
	end

	--如果capslock键已按下则启动循环，否则退出循环
	while (IsKeyLockOn("capslock")) do
		Sleep(Hege_Macro_LoopInterval) --循环间隔

		Times_Key_1 = Times_Key_1 + 1
		Times_Key_2 = Times_Key_2 + 1
		Times_Key_3 = Times_Key_3 + 1
		Times_Key_4 = Times_Key_4 + 1
		Times_Key_5 = Times_Key_5 + 1
		Times_Key_6 = Times_Key_6 + 1

		--每N秒按下并释放1键
		if ((Times_Key_1*Hege_Macro_LoopInterval) >= 200) then
			--PressAndReleaseKey("1")
			Times_Key_1 = 0
		end

		--每N秒按下并释放2键
		if ((Times_Key_2*Hege_Macro_LoopInterval) >= 200) then
			PressAndReleaseKey("2")
			Times_Key_2 = 0
		end

		--每N秒按下并释放3键
		if ((Times_Key_3*Hege_Macro_LoopInterval) >= 500050) then
			PressAndReleaseKey("3")
			Times_Key_3 = 0
		end

		--每N秒按下并释放4键
		if ((Times_Key_4*Hege_Macro_LoopInterval) >= 500070) then
			PressAndReleaseKey("4")
			Times_Key_4 = 0
		end

		--每N秒按下并释放鼠标左键
		if ((Times_Key_5*Hege_Macro_LoopInterval) >= 500000) then
			PressKey("f2")
			Sleep(20)
			PressAndReleaseMouseButton(1)--点击左键
			Sleep(25)
			ReleaseKey("f2")
			Times_Key_5 = 0
		end

		--每N秒按下并释放鼠标右键
		if ((Times_Key_6*Hege_Macro_LoopInterval) >= 2000) then
			--PressAndReleaseMouseButton(3)--点击右键
			Times_Key_6 = 0
		end

		if (IsModifierPressed("rshift")) then --按住rshift键中断技能
			ReleaseMouseButton(3)--释放鼠标右键
			Sleep(10)
			ReleaseKey("f2")--释放F2键（强制站立）
			Sleep(10)
			PressAndReleaseMouseButton(1)--按下左键
		else
			if not (IsMouseButtonPressed(3)) then  --如果右键没有按下
				ReleaseMouseButton(3)--释放鼠标右键
				Sleep(10)
				PressMouseButton(3)--按下鼠标右键
			end
		end
	end

	--循环结束，释放鼠标
	ReleaseMouseButton(3)--释放鼠标右键
	ReleaseKey("f2")--释放F2键（强制站立）
    Sleep(500)
    PressAndReleaseKey("f3")--点击F3键（暗黑3导航功能键：快速拾取装备、分解背包装备、血岩购买装备）
end